// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   CEImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.LIST_CR;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;
import com.sunwayhorizo.health.hl7.datatypes.UID;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            CDImpl, ANYImpl, BLImpl, CSImpl, 
//            EDImpl, LIST_CRAdapterImpl, NullFlavorImpl, OIDImpl, 
//            SET_CDImpl, SET_CEImpl, STImpl, TYPEImpl

public class CEImpl extends CDImpl
    implements CE
{

    public static final String RCS_ID = "$Header: CEImpl.java 115.30 2005/09/16 10:39:33 mmoores noship $";
    private static final CE nullNI = new CEImpl(CSImpl.valueOf("NI"));
    private static final CE nullOTH = new CEImpl(CSImpl.valueOf("OTH"));
    private static final CE nullNINF = new CEImpl(CSImpl.valueOf("NINF"));
    private static final CE nullPINF = new CEImpl(CSImpl.valueOf("PINF"));
    private static final CE nullUNK = new CEImpl(CSImpl.valueOf("UNK"));
    private static final CE nullASKU = new CEImpl(CSImpl.valueOf("ASKU"));
    private static final CE nullNAV = new CEImpl(CSImpl.valueOf("NAV"));
    private static final CE nullMSK = new CEImpl(CSImpl.valueOf("MSK"));
    private static final CE nullNA = new CEImpl(CSImpl.valueOf("NA"));
    private static final CE nullNASK = new CEImpl(CSImpl.valueOf("NASK"));
     
    /**
     * 增加构造方法，调用的是父类的构造方法
     * @param flag 
     * @param code
     */
    protected CEImpl(ST code){
    	super(null,code);
    }
    	
    
    /**
     * 增加构造方法
     * @param code
     * @param codeSystem 
     * @param codeSystemEnName  //ets术语字典英文名
     * @param codeSystemChName  //ets术语字典中文名
     * @param codeName  //ets术语名称
     * @param codeSystemVersion
     */
    protected CEImpl(ST code,UID codeSystem,ST codeSystemEnName,ST codeSystemChName,ST codeName,ST codeSystemVersion){
    	super(code,codeSystem,codeSystemEnName,codeSystemChName,codeName,codeSystemVersion);
    }
    
    /** //2012 10 23 注释
     * 修改构造方法，增加参数ST st4, ST st5
     * @param st
     * @param uid
     * @param st1
     * @param st2
     * @param st3
     * @param st4
     * @param st5
     * @param ed
     * @param set_cd
     */
//    protected CEImpl(ST st, UID uid, ST st1, ST st2, ST st3,ST st4, ST st5, ED ed, SET_CD set_cd)
//    {
//        super(st, uid, st1, st2, st3, st4, st5,ed, null, set_cd);
//    }
    
    /** //2012 10 23 注释
     * 修改构造方法，增加参数ST st4, ST st5
     * @param etsservice
     * @param st
     * @param uid
     * @param st1
     * @param st2
     * @param st3
     * @param st4
     * @param st5
     * @param ed
     * @param set_cd
     * @throws ETSException
     */
//    protected CEImpl(ETSService etsservice, ST st, UID uid, ST st1, ST st2, ST st3,ST st4, ST st5, ED ed, 
//            SET_CD set_cd)
//        throws ETSException
//    {
//        super(etsservice, st, uid, st1, st2, st3,st4,st5, ed, null, set_cd);
//    }

    protected CEImpl(CS cs)
    {
        super(cs);
    }

    public LIST_CR qualifier()
    {
        return LIST_CRAdapterImpl.nullLIST_CR(NullFlavorImpl.NA);
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.CE;
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
        {
            i = 37 * i + code().hashCode();
            i = 37 * i + codeSystem().hashCode();
        }
        return i;
    }

    public BL equal(ANY any)
    {
        if(any instanceof CE)
        {
            if(any.isNull().isTrue())
            {
                return BLImpl.FALSE;
            } else
            {
                CE ce = (CE)any;
                return code().equal(ce.code()).and(codeSystem().equal(ce.codeSystem()));
            }
        } else
        {
            return BLImpl.FALSE;
        }
    }

    /**
     * 修改valueOf方法，增加参数 String s4, String s5
     *    /** //2012 10 23 注释

     * jinzw
     * 2010-11-15
     * @return
     */
//    public static CD valueOf(String s, String s1, String s2, String s3, String s4, String s5, ED ed)
//    {
//        ST st = s == null ? STImpl.nullST(NullFlavorImpl.NI) : STImpl.valueOf(s);
//        com.sunwayhorizo.health.hl7.datatypes.OID oid = s1 == null ? OIDImpl.nullOID(NullFlavorImpl.NI) : OIDImpl.valueOf(s1);
//        ST st1 = s2 == null ? STImpl.nullST(NullFlavorImpl.NI) : STImpl.valueOf(s2);
//        ST st2 = s3 == null ? STImpl.nullST(NullFlavorImpl.NI) : STImpl.valueOf(s3);
//        ST st3 = s4 == null ? STImpl.nullST(NullFlavorImpl.NI) : STImpl.valueOf(s4);
//        ST st4 = s5 == null ? STImpl.nullST(NullFlavorImpl.NI) : STImpl.valueOf(s5);
//        ST st5 = STImpl.nullST(NullFlavorImpl.NI);
//        LIST_CR list_cr = LIST_CRAdapterImpl.nullLIST_CR(NullFlavorImpl.NI);
//        SET_CD set_cd = SET_CDImpl.nullSET_CD(NullFlavorImpl.NI);
//        return new CDImpl(st, oid, st1, st2, st3,st4, st5, ed, list_cr, set_cd);
//    }

    /**
     * 修改valueOf方法，增加参数ST st4, ST st5
     *    //2012 10 23 注释

     * jinzw
     * 2010-11-15
     * @return
     * @throws ETSException
     */
//    public static CE valueOf(ETSService etsservice, ST st, UID uid, ST st1, ST st2, ST st3, ST st4, ST st5, ED ed, SET_CD set_cd)
//        throws ETSException
//    {
//        return new CEImpl(etsservice, st, uid, st1, st2, st3,st4,st5,ed, set_cd);
//    }

    /**
     * 修改返回值错误
     *     //2012 10 23 注释

     * jinzw
     * 2010-11-15
     * @param s
     * @param s1
     * @return
     */
//    public static CD valueOf(String s, String s1)
//    {
//        ST st = STImpl.valueOf(s);
//        com.sunwayhorizo.health.hl7.datatypes.OID oid = OIDImpl.valueOf(s1);
//        ST st1 = STImpl.nullST(NullFlavorImpl.NI);
//        return new CEImpl(st, oid, st1, st1, st1, st1, st1, EDImpl.nullED(NullFlavorImpl.NI), SET_CDImpl.nullSET_CD(NullFlavorImpl.NI));
//    }
    
    
    /**
     * 增加一个创建CE的方法
     * jinzw
     * 2010-11-19
     * @param code
     * @return
     */
    public static CE valueOf(String code){
    	ST st = STImpl.valueOf(code);
       return new CEImpl(st); 	
    }
    
    /**
     * 增加创建CE的方法
     * jinzw
     * 2010-11-19
     * @param code
     * @param codeSystem
     * @param codeSystemEnName
     * @param codeSystemChName
     * @param codeName
     * @param codeSystemVersion
     * @return
     */
    public static CE valueOf(String code,String codeSystem,String codeSystemEnName,String codeSystemChName,String codeName,String codeSystemVersion){
    	ST scode = STImpl.valueOf(code);
    	UID ucodeSystem = UIDImpl.valueOf(codeSystem);
    	ST scodeSystemEnName = STImpl.valueOf(codeSystemEnName);
    	ST scodeSystemChName = STImpl.valueOf(codeSystemChName);
    	ST scodeName = STImpl.valueOf(codeName);
    	ST scodeSystemVersion = STImpl.valueOf(codeSystemVersion);
    	return new CEImpl(scode,ucodeSystem,scodeSystemEnName,scodeSystemChName,scodeName,scodeSystemVersion);
    }
    
    
     //2012 10 23 注释
//    public static CD valueOf(ETSService etsservice, String s)
//        throws ETSException
//    {
//        String as[] = {
//            s
//        };
//        SET_CE set_ce = SET_CEImpl.newSET_CE(etsservice, as);
//        CE ace[] = (CE[])set_ce.toSet().toArray(new CE[0]);
//        if(ace != null && ace.length != 0)
//            return ace[0];
//        else
//            throw new ETSNotFoundException("ETS ID passed in is not valid");
//    }

    public static CE nullCE(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
